/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package deatax.markers;

import deatax.GameData;
import deatax.Player;
import deatax.display.BoardRenderer;
import deatax.display.Model;
import deatax.display.ModelLoader;
import deatax.display.Texture;
import deatax.display.particle.AlphaRule;
import deatax.display.particle.ParticleRule;
import deatax.display.particle.ParticleSpawn;
import deatax.display.particle.ScaleRule;
import deatax.display.particle.VectorRule;
import java.io.FileNotFoundException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.opengl.GL2;

/**
 *
 * @author Caroline
 */
public class HouseMarker extends Marker {

    public static Model house = houseInit();
    ParticleSpawn particles;

    public HouseMarker(Player owner) {
        super(owner);

        particles = new ParticleSpawn(new float[]{0.03f, -0.095f, 0.4f}, 10, 0.5f, 3, 0.1f, new ParticleRule[]{
                    new VectorRule(new float[]{0, 0, 0.3f}, new float[]{1.5f, 0, -0.8f}, 0.1f, 0, 0.4f)
                    ,new AlphaRule(-0.3f, 0, 1)
                    ,new ScaleRule(0.01f, 0.005f, 2)
                }, new Texture("display/particle/smoke.png"));
//        particles = new ParticleSpawn(new float[]{0, 0, 0}, 50, 0.5f, 10, 0, new ParticleRule[]{
//                    new VectorRule(new float[]{0, 0, 1f}, new float[]{0.8f, 0, -1}, 0.5f, 0, 0.8f),
//                    new AlphaRule(-0.3f, 0, 1),
//                    new ScaleRule(0.1f, 0.1f, 2)
//                }, new Texture("display/particle/smoke.png"));
    }

    public static Model houseInit() {
        Model m = null;
        try {
            m = ModelLoader.loadModel("markers/settlement.obj");
            m.setTexture(new Texture("markers/settlement.png"));
            m.normalise();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Marker.class.getName()).log(Level.SEVERE, null, ex);
        }
        return m;
    }

    @Override
    public void drawP1(GL2 gl) {
        float scale = 1.5f;
        gl.glScalef(scale,scale,scale);
        drawBase(gl);
        scale = 1/scale;
        
        gl.glScalef(scale,scale,scale);
        gl.glTranslatef(0, 0, 0.05f);
        house.draw(gl);
        gl.glTranslatef(0, 0, -0.05f);
        
    }

    @Override
    public void drawP2(GL2 gl) {
        if (GameData.checkLOD(GameData.LOD_PARTICLES) && particles != null) {
            particles.draw(BoardRenderer.tickScale, gl);
        }
    }
    
    
}
